package com.mysiteforme.admin.util.date;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.springframework.stereotype.Component;

/*
 * 日期：每周一和每周日的方法
 */

@Component
public class DateWeek {
	public String monday() {
		Calendar cal = Calendar.getInstance();
		//n为推迟复的周数，制1本周，bai-1向前推迟一周，2下周，依次类推du
		int n = -1;
		String monday;
		cal.add(Calendar.DATE, n*7);
		//想周几，这里zhi就传几daoCalendar.MONDAY（TUESDAY...）
		cal.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
		monday = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
		return monday;
	}
	public String sunday() {
		Calendar cal = Calendar.getInstance();
		int nn = 0;
		String sunday;
		cal.add(Calendar.DATE, nn*7);
		//想周几，这里zhi就传几daoCalendar.MONDAY（TUESDAY...）
		cal.set(Calendar.DAY_OF_WEEK,Calendar.SUNDAY);
		sunday = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
		return sunday;
	}
}
